//
//  ClassificationModel.m
//  SmallEasyLife
//
//  Created by imac on 11/2/15.
//  Copyright © 2015 GXK. All rights reserved.
//

#import "ClassificationModel.h"
#import "Tags.h"
@implementation ClassificationModel

+ (instancetype)classificationWithDictionary:(NSDictionary *)dictionary
{
    return [[self alloc]initWithDictionary:dictionary];
}

- (instancetype)initWithDictionary:(NSDictionary *)dictionary
{
    if (self = [super init]) {
        self.title = dictionary[@"title"];
        self.identifier = dictionary[@"id"];
        NSArray *tagsArray = dictionary[@"tags"];
        NSMutableArray *mutableTags = [[NSMutableArray alloc]initWithCapacity:tagsArray.count];
        [mutableTags enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            Tags *tags = [Tags tagsWithDictionary:obj];
            [mutableTags addObject:tags];
        }];
        self.tags = mutableTags;
    }
    
    return self;
}

- (NSString *)description
{
    return [NSString stringWithFormat:@"title:%@, tags:%@, id:%@",self.title,self.tags,self.identifier];
}

@end
